package com.qf.service.impl;

import com.qf.entity.User;
import com.qf.mapper.UserMapper;
import com.qf.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
    @Override
    public User login(User user) {

        return userMapper.login(user);
    }

    @Override
    public List<User> findAll() {
        List<User> users = userMapper.findAll();
        return users != null ? users : new ArrayList<>();
    }
    @Override
    public User findByUsername(String username) {
        return userMapper.findByUsername( username);
    }
    @Override
    public void register(User user) {
        userMapper.register(user);
    }

    @Override
    public void delete(Integer id) {
        userMapper.delete(id);
    }

    @Override
    public void batchDeleteUser(List<Integer> ids) {
        userMapper.batchDeleteUser(ids);
    }

    @Override
    public List<User> findByUsernameLike(String username) {
        List<User> users = userMapper.findByUsernameLike(username);
        return users != null ? users : new ArrayList<>();
    }


}
